package com.haina.shop.controller.index;

import com.haina.shop.domain.Notice;
import com.haina.shop.result.IPageIndexImg;
import com.haina.shop.result.ServiceResult;
import com.haina.shop.service.NoticeService;
import com.haina.shop.vo.NoticeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop/notice")
public class NoticeController {
    @Autowired
    private NoticeService service;
    /**
     * 获取所有置顶公告列表信息
     */
    @GetMapping("/topNoticeList")
    public ServiceResult<List<NoticeVO>> getTopNoticeList(){
         return service.getTopNoticeList();
    }

    /**
     * 获取所有公告列表信息
     * @return
     */
    @GetMapping("/noticeList")
    public ServiceResult<IPageIndexImg<NoticeVO>> getNoticeList(){
        return service.getNoticeList();
    }

    /**
     * 获取公告id公告详情
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    public ServiceResult<NoticeVO> getById(@PathVariable Long id){
        return service.getDataById(id);
    }
}
